
<script type="text/JAVASCRIPT">

function getlatlong() {
	$('#mymap').show();
	var geocoder = new google.maps.Geocoder();
	
	var street=$("#address1").val();
	var state=$("#statediv option:selected").html();
	var city=$("#citydiv option:selected").html();
	
	//var address=country+','+state+','+city+','+street;
	var address=street+','+city+','+state;
	
	geocoder.geocode( { 'address': address}, function(results, status) {

	if (status == google.maps.GeocoderStatus.OK) {
    var latitude = results[0].geometry.location.lat();
	var longitude = results[0].geometry.location.lng();
	document.getElementById('lat').value=latitude;
	document.getElementById('long').value=longitude;
    } 

	
    var latlng = new google.maps.LatLng(latitude,longitude);
    var map = new google.maps.Map(document.getElementById('map'), {
        center: latlng,
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: 'Set lat/lon values for this property',
        draggable: true
    });
    google.maps.event.addListener(marker, 'dragend', function(a) {
        console.log(a);
       
        
		document.getElementById('lat').value = a.latLng.lat().toFixed(4);
		document.getElementById('long').value = a.latLng.lng().toFixed(4);
        document.getElementsByTagName('body')[0].appendChild(div);
    });
	}); 
};

</script>
<style>

#map {
	height: 300px;
	border: 1px solid #000;
}
</style>


<?php if($mode == "ADD"){?>

<section class="wrapper">


	<div class="col-lg-12">
		<!--work progress start-->
		<section class="panel">

			<div class="inbox-head">
				<h3>ADD LISTING</h3>
			</div>



			<div class="panel-body">

				<div class="col-xs-12 clearfix">


					<form class="form-horizontal" method="POST" action="<?= base_url();?>secure/listing/submit_business">
						<?php
						if($this->session->flashdata('message'))
						{
							$msgs = $this->session->flashdata('message');
							echo  $this->session->flashdata('message');
						}
						?>
						<span class="text text-danger pull-right"> * marks fields are
							mandatory </span> <input type="hidden"
							name="<?php echo $this->security->get_csrf_token_name(); ?>"
							value="<?php echo $this->security->get_csrf_hash();?>" />
						<div class="text text-warning">
							<h4>
								<strong>General Information</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">Business Name <span
								class="text text-danger">*</span>
							</label>
							<div class="col-sm-8">
								<span class="text text-danger"> <?php echo form_error('business_name'); ?>
								</span> <input type="text" name="business_name"
									id="business_name" class="form-control"
									placeholder="Type your Business Name">


							</div>
						</div>


						<div class="form-group">
							<label class="col-sm-3 control-label">Parent Category <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('category'); ?>
								</span>
								<?php if(isset($category)){ ?>
								<select class="form-control" name="category" id="category">
									<option value="" selected="selected">--Select Category--</option>
									<?php foreach($category as $category):?>
									<option value="<?= $category->id;?>"><?= $category->name;?></option>
									<?php endforeach;?>
								</select>
								<?php }?>


							</div>
						</div>


						<div class="form-group">
							<label class="col-sm-3 control-label">Sub Category</label>

							<div class="col-sm-5 ">
								<select class="form-control" name="sub_category"
									id="sub_category" disabled="disabled">
									
								</select>


							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label">Keyword</label>

							<div class="col-sm-5 ">
								<div class="text text-info">Select Multiple keyword CTRL+CLICK</div>
								<select multiple="multiple" class="form-control"
									name="keyword[]" id="keyword" size='10' disabled="disabled">
								</select>
							</div>
						</div>


						<div id="statediv" class="form-group" onClick="getlatlong()">
							<label class="col-sm-3 control-label">Region <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('region'); ?>
								</span>
								<?php if(isset($region)){?>
								<select class="form-control" name="region" id="region">
									<option value="" selected="selected">--Select Region--</option>
									<?php foreach($region as $region):?>
									<option value="<?= $region->id;?>"
									>
										<?= $region->name;?>
									</option>
									<?php endforeach;?>
								</select>
								<?php }?>
							</div>
						</div>
						<div id="citydiv" class="form-group" onClick="getlatlong()">
							<label class="col-sm-3 control-label">City <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('city'); ?>
								</span>
								<select class="form-control" name="city" id="city" disabled="disabled">
								<option value=""></option>
								</select>
													</div>
						</div>
						<div class="form-group" onClick="getlatlong()">
							<label class="col-sm-3 control-label">Address <span
								class="text text-danger">*</span>
							</label>
							<div class="col-sm-6">
								<span class="text text-danger"> <?php echo form_error('address1'); ?>
								</span> <input type="text" name="address1" id="address1"
									class="form-control" placeholder="Address"
								>
							</div>
						</div>

						<div class="form-group" style="display: none" id="mymap">
							<label class="col-sm-3 control-label">Select Place*</label>
							<div class="col-sm-8 ">
								<div id="map"></div>
							</div>
						</div>

						<div class="form-group" hidden="hidden">
							<label class="col-sm-2 control-label">Longitude</label>

							<div class="col-sm-4 ">
								<input type="text" name="long" id="long" class="form-control"
									>



							</div>
							<label class="col-sm-2 control-label">Latitude</label>
							<div class="col-sm-4 ">
								<input type="text" name="lat" id="lat" class="form-control"
									>



							</div>
						</div>

						<div class="text text-warning">
							<h4>
								<strong>Address Information</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">Zip Code <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('zip_code'); ?>
								</span> <input type="text" name="zip_code" id="zip_code"
									class="form-control" placeholder="Zip Code"
									>



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Fax No</label>

							<div class="col-sm-5 ">
								<input type="text" name="fax_no" id="fax_no"
									class="form-control" placeholder="Fax No"
									>



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Phone No <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-4 ">
								<span class="text text-danger"> <?php echo form_error('primary'); ?>
								</span> <input type="text" name="primary" id="primary"
									class="form-control" placeholder="Primary"
									>



							</div>
							<div class="col-sm-4 ">
								<input type="text" name="secondary" id="secondary"
									class="form-control" placeholder="Secondary"
									>



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Toll Free</label>

							<div class="col-sm-5 ">
								<input type="text" name="toll_free" id="toll_free"
									class="form-control" placeholder="Toll Free"
									>



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Business Email <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('business_email'); ?>
								</span> <input type="text" name="business_email"
									id="business_email" class="form-control"
									placeholder="Business Email" >



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Website Url</label>

							<div class="col-sm-5 ">
								<input type="text" name="website_url" id="website_url"
									class="form-control" placeholder="Website Url"
									>



							</div>
						</div>
						<div class="text text-warning">
							<h4>
								<strong>Contact Phone Numbers and Persons</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">Contact Person(1)</label>

							<div class="col-sm-4 ">
								<input type="text" name="contact_name" id="contact_name"
									class="form-control" placeholder="Contact Name"
									>



							</div>
							<div class="col-sm-4 ">
								<input type="text" name="contact_number" id="contact_number"
									class="form-control" placeholder="Phone Number"
									>



							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label">Contact Person(2)</label>

							<div class="col-sm-4 ">
								<input type="text" name="contact_name_2" id="contact_name_2"
									class="form-control" placeholder="Contact Name"
									>



							</div>
							<div class="col-sm-4 ">
								<input type="text" name="contact_number_2" id="contact_number_2"
									class="form-control" placeholder="Phone Number"
									>



							</div>
						</div>
						<div class="text text-warning">
							<h4>
								<strong>About Your Business</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">About Business <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-9 ">
								<span class="text text-danger"> <?php echo form_error('description'); ?>
								</span>
							<textarea class="form-control" rows="7" name="description" id="description"></textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Product and Services <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-9 ">
								<span class="text text-danger"> <?php echo form_error('services'); ?>
								</span>
								<textarea class="form-control" rows="7" name="services" id="services"></textarea>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-3 col-sm-9">
								
								<button type="submit" class="btn btn-info" <?php if($this->config->item('mode')=='DEMO'){?>onclick="alert ('Sorry! Not allowed in Demo mode '); return false;" <?} else?>onclick="return confirm('Are you sure ?');"  >Save & Continue</button>


							</div>
						</div>
					</form>
				</div>
			</div>
		</section>
	</div>
</section>

<?php }?>



<?php if($mode == "EDIT"){?>
<style>
#map5 {
	height: 300px;
	border: 1px solid #000;
}
</style>
<script type="text/javascript">
						





</script>

<section class="wrapper">


	<div class="col-lg-12">
		<!--work progress start-->
		<section class="panel">

			<div class="inbox-head">
				<h3>
					EDIT LISTING :
					<?= $business['title'];?>
				</h3>
				<a href="<?= base_url();?>banner/admin/banner/add"><button
						type="button" class="btn btn-danger pull-right">
						<i class="icon-plus"></i>
					</button> </a>
			</div>



			<div class="panel-body">

				<div class="col-xs-12 clearfix">


					<form class="form-horizontal" method="POST"
						action="<?= base_url();?>secure/listing/update_business/<?= $business['id'];?>">
						<?php
						if($this->session->flashdata('message'))
						{
							$msgs = $this->session->flashdata('message');
							echo  $this->session->flashdata('message');
						}
						?>
						<span class="text text-danger pull-right"> * marks fields are
							mandatory </span> <input type="hidden"
							name="<?php echo $this->security->get_csrf_token_name(); ?>"
							value="<?php echo $this->security->get_csrf_hash();?>" />
						<div class="text text-warning">
							<h4>
								<strong>General Information</strong>
							</h4>
						</div>
						<hr>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">Mem Name
                            </label>
                            <div class="col-sm-3">
                                <select class="form-control" name="memname" id="memname">
                                    <option value="" selected="selected">--Select Member--</option>
                                    <?php foreach($member as $member):?>
                                        <option value="<?= $member->id;?>" <?php if($member->id == $business['mem_id']) {echo "selected=selected";}?>?>
                                        <?=$member->name;?>
                                        </option>
                                    <?php endforeach;?>

                                </select>


                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">Feature
                            </label>
                            <div class="col-sm-3">
                                <select class="form-control" name="plan" id="plan">
                                    <option value="" selected="selected">--Select Plan--</option>
                                    <?php foreach($plan as $plan):?>
                                        <option value="<?= $plan->id;?>" <?php if($plan->id == $business['plan']) {echo "selected=selected";}?>?>
                                        <?=$plan->name;?>
                                        </option>
                                    <?php endforeach;?>

                                </select>


                            </div>
                        </div>

						<div class="form-group">
							<label class="col-sm-3 control-label">Business Name <span
								class="text text-danger">*</span>
							</label>
							<div class="col-sm-8">
								<span class="text text-danger"> <?php echo form_error('business_name'); ?>
								</span> <input type="text" name="business_name"
									id="business_name" class="form-control"
									placeholder="Type your Business Name"
									value="<?= $business['title'];?>">


							</div>
						</div>


						<div class="form-group">
							<label class="col-sm-3 control-label">Parent Category <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('category'); ?>
								</span>
								<?php if(isset($category)){ ?>
								<select class="form-control" name="category" id="category">
									<option value="" selected="selected">--Select Category--</option>
									<?php foreach($category as $category):?>
									<option value="<?= $category->id;?>"
									<?php if($category->id == $catID){echo "selected=selected";}?>>
										<?= $category->name;?>
									</option>
									<?php endforeach;?>
								</select>
								<?php }?>


							</div>
						</div>


						<div class="form-group">
							<label class="col-sm-3 control-label">Sub Category</label>

							<div class="col-sm-5 ">
								<?php if(isset($subcategory)){ ?>
								<select class="form-control" name="sub_category"
									id="sub_category">
									<option value="" selected="selected">--Select Sub-Category--</option>

									<?php foreach($subcategory as $subcategory):?>
									<option value="<?= $subcategory->id;?>"
									<?php if($subcategory->id == $subcatID){echo "selected=selected";}?>>
										<?= $subcategory->name;?>
									</option>
									<?php endforeach;?>

								</select>
								<?php }?>


							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label">Keyword</label>

							<div class="col-sm-5 ">
								<div class="text text-info">Select Multiple keyword CTRL+CLICK</div>
								<?php if(isset($keyword)){?>
								<select multiple="multiple" class="form-control"
									name="keyword[]" id="keyword" size='10'>
									<option value="">-- -- -- -- -Select Keyword-- -- -- --</option>
									<?php foreach($keyword as $keyword):?>


									<?php $keywordID = $this->term_model->getKeyword($business['id'],$keyword->id);?>

									<option value="<?= $keyword->id;?>"
									<?php if($keywordID == $keyword->id)
							{echo "selected=selected";}?>>
										<?= $keyword->name;?>
									</option>
									<?php endforeach;?>
								</select>
								<?php }?>
							</div>
						</div>


						<div id="statediv" class="form-group" onClick="getlatttttlong()">
							<label class="col-sm-3 control-label">Region <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('region'); ?>
								</span>
								<?php if(isset($region)){?>
								<select class="form-control" name="region" id="region">
									<option value="" selected="selected">--Select Region--</option>
									<?php foreach($region as $region):?>
									<option value="<?= $region->id;?>"
									<?php if($region->id == $regionID){echo "selected=selected";}?>>
										<?= $region->name;?>
									</option>
									<?php endforeach;?>
								</select>
								<?php }?>
							</div>
						</div>
						<div id="citydiv" class="form-group" onClick="getlatttttlong()">
							<label class="col-sm-3 control-label">City <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('city'); ?>
								</span>
								<?php if(isset($cityname)){?>
								<select class="form-control" name="city" id="city">
									<?php foreach($cityname as $cityname):?>
									<option value="<?= $cityname->id;?>"
									<?php if($cityname->id == $cityID){echo "selected=selected";}?>>
										<?= $cityname->name;?>
									</option>
									<?php endforeach;?>
								</select>
								<?php }?>


							</div>
						</div>
						<div class="form-group" onClick="getlatttttlong()">
							<label class="col-sm-3 control-label">Address <span
								class="text text-danger">*</span>
							</label>
							<div class="col-sm-6">
								<span class="text text-danger"> <?php echo form_error('address1'); ?>
								</span> <input type="text" name="address1" id="address1"
									class="form-control" placeholder="Type your Business Name"
									value="<?= $business['address1'];?>">
							</div>
						</div>

						<div class="form-group" id="mymap5">
							<label class="col-sm-3 control-label">Select Place*</label>
							<div class="col-sm-8 ">
								<div id="map5"></div>
							</div>
						</div>

						<div class="form-group" hidden="hidden">
							<label class="col-sm-2 control-label">Longitude</label>

							<div class="col-sm-4 ">
								<input type="text" name="long" id="long" class="form-control"
									value="<?= $business['long'];?>">



							</div>
							<label class="col-sm-2 control-label">Latitude</label>
							<div class="col-sm-4 ">
								<input type="text" name="lat" id="lat" class="form-control"
									value="<?= $business['lat'];?>">



							</div>
						</div>

						<div class="text text-warning">
							<h4>
								<strong>Address Information</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">Zip Code <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('zip_code'); ?>
								</span> <input type="text" name="zip_code" id="zip_code"
									class="form-control" placeholder="Zip Code"
									value="<?= $business['zip_code'];?> ">



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Fax No</label>

							<div class="col-sm-5 ">
								<input type="text" name="fax_no" id="fax_no"
									class="form-control" placeholder="Fax No"
									value="<?= $business['fax'];?>">



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Phone No <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-4 ">
								<span class="text text-danger"> <?php echo form_error('primary'); ?>
								</span> <input type="text" name="primary" id="primary"
									class="form-control" placeholder="Primary"
									value="<?= $business['phone1'];?>">



							</div>
							<div class="col-sm-4 ">
								<input type="text" name="secondary" id="secondary"
									class="form-control" placeholder="Secondary"
									value="<?= $business['phone2'];?>">



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Toll Free</label>

							<div class="col-sm-5 ">
								<input type="text" name="toll_free" id="toll_free"
									class="form-control" placeholder="Toll Free"
									value="<?= $business['toll_free'];?>">



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Business Email <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-5 ">
								<span class="text text-danger"> <?php echo form_error('business_email'); ?>
								</span> <input type="text" name="business_email"
									id="business_email" class="form-control"
									placeholder="Business Email" value="<?= $business['email'];?>">



							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Website Url</label>

							<div class="col-sm-5 ">
								<input type="text" name="website_url" id="website_url"
									class="form-control" placeholder="Website Url"
									value="<?= $business['website'];?>">



							</div>
						</div>
						<div class="text text-warning">
							<h4>
								<strong>Contact Phone Numbers and Persons</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">Contact Person(1)</label>

							<div class="col-sm-4 ">
								<input type="text" name="contact_name" id="contact_name"
									class="form-control" placeholder="Contact Name"
									value="<?= $business['contact_name'];?>">



							</div>
							<div class="col-sm-4 ">
								<input type="text" name="contact_number" id="contact_number"
									class="form-control" placeholder="Phone Number"
									value="<?= $business['contact_no'];?>">



							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-3 control-label">Contact Person(2)</label>

							<div class="col-sm-4 ">
								<input type="text" name="contact_name_2" id="contact_name_2"
									class="form-control" placeholder="Contact Name"
									value="<?= $business['contact_name2'];?>">



							</div>
							<div class="col-sm-4 ">
								<input type="text" name="contact_number_2" id="contact_number_2"
									class="form-control" placeholder="Phone Number"
									value="<?= $business['contact_no2'];?>">



							</div>
						</div>
						<div class="text text-warning">
							<h4>
								<strong>About Your Business</strong>
							</h4>
						</div>
						<hr>
						<div class="form-group">
							<label class="col-sm-3 control-label">About Business <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-9 ">
								<span class="text text-danger"> <?php echo form_error('description'); ?>
								</span>
								<textarea class="form-control" rows="7" name="description"
									id="description">
									<?= $business['description'];?>
								</textarea>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-3 control-label">Product and Services <span
								class="text text-danger">*</span>
							</label>

							<div class="col-sm-9 ">
								<span class="text text-danger"> <?php echo form_error('services'); ?>
								</span>
								<textarea class="form-control" rows="7" name="services"
									id="services">
									<?= $business['services'];?>
								</textarea>
							</div>
						</div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">Verified
                            </label>
                            <div class="col-sm-3">
                                <select class="form-control" name="verified" id="verified">
                                    <option value="" selected="selected">--Select--</option>
                                        <option value="Yes" <?php if($business['verified'] == 'Yes') {echo "selected=selected";}?>>Yes</option>
                                    <option value="Yes" <?php if($business['verified'] == 'No') {echo "selected=selected";}?>>No</option>
                                </select>


                            </div>
                        </div>
						<div class="form-group">
							<div class="col-sm-offset-3 col-sm-9">
								<input type="hidden" name="post_id" id="post_id"
									value="<?= $business['id'];?>">
								<button type="submit" class="btn btn-info">Update</button>


							</div>
						</div>
					</form>
				</div>
			</div>
		</section>
	</div>
</section>

<?php }?>

